package threadpool;

import cn.hutool.core.thread.NamedThreadFactory;
import cn.hutool.core.thread.ThreadFactoryBuilder;

import java.util.concurrent.*;

public class ThreadPoolTest {

    static ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 20, 60, TimeUnit.SECONDS,
            new LinkedBlockingQueue<>(100),
            new ThreadFactoryBuilder().setNamePrefix("thread-pool-name-1").build(),
            new ThreadPoolExecutor.AbortPolicy());


    public static void main(String[] args) throws Exception {
        System.out.println(1);
        executor.execute(ThreadPoolTest::doing);
        Future<String> submit = executor.submit(ThreadPoolTest::testCallback);
        System.out.println(submit.get());

//        ThreadPoolTest threadPoolTest = new ThreadPoolTest();
//        threadPoolTest.executorService.execute(ThreadPoolTest::doing);

        System.out.println("==="+ctlOf(-1, 0));
    }

    private static String testCallback() {
        return "testcallback";
    }

    private static void doing() {
        System.out.println(2);
    }

    private static int ctlOf(int rs, int wc) { return rs | wc; }


}
